/*
 * @Description:
 * @Author: mmzhang
 * @Date: 2022-01-05 11:38:09
 * @LastEditTime: 2022-07-28 15:19:26
 */
import dt from '@dt/dt'
export const linkOrder = {
  data() {
    return {}
  },
  methods: {
    linkOrderFun(orderParams) {
      // 认购: 'RG',
      // 退购: 'UR',
      // 签约: 'QY',
      // 退签: 'UQ',
      // 认购调整: 'TR',
      // 签约调整: 'TQ',
      /**
       *  orderNum: row.orderCode, // 单号
          businessId: row.orderId, // 业务id
          buildingId: this.$dt.buildInfo().housesId, //楼盘id
          subscriptionId: '' //签约单对应的认购单id
       */
      let type = orderParams.orderNum.slice(0, 2)
      let isSummary = this.$route.query.isSummary
      let returnNote = this.$route.query.returnNote ? this.$route.query.returnNote : orderParams.returnNote
      let returnPurchase = this.$route.query.returnPurchase
        ? this.$route.query.returnPurchase
        : orderParams.returnPurchase
      let isView = this.$route.meta.isbuild == 'nobuildpage' ? true : false // 是否案场外跳转
      let ApproveManagementFlag = this.$route.query.ApproveManagementFlag ? true : false
      console.log(isView, returnNote, returnPurchase, isSummary, 'dddddddddd')

      // 自获客预发表
      let cusPreFlag = this.$route.query.cusPreFlag? this.$route.query.cusPreFlag: orderParams.cusPreFlag

      switch (type) {
        case 'RG':
          if (!this.unlocking('0104010300')) {
            this.$Message.info('无权限！')
            return false
          }

          this.$router.push({
            name: !isView ? 'subscriptionDetail' : 'viewSubscriptionDetail',
            query: {
              examineBtn: false,
              ApproveManagementFlag,
              orderStatusName: '认购',
              ...orderParams,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/subSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/subApprove'
            }
          })
          break
        case 'UR':
          if (!this.unlocking('0104020200')) {
            this.$Message.info('无权限！')
            return false
          }
          this.$router.push({
            name: !isView ? 'backOrderDetail' : 'viewBackOrderDetail',
            query: {
              examineBtn: false,
              ApproveManagementFlag,
              orderStatusName: '退购',
              ...orderParams,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/subSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/subApprove'
            }
          })
          break
        case 'QY':
          if (!this.unlocking('0104030300')) {
            this.$Message.info('无权限！')
            return false
          }
          this.$router.push({
            name: !isView ? 'contractDetail' : 'viewContractDetail',
            query: {
              examineBtn: false,
              ApproveManagementFlag,
              orderStatusName: '签约',
              ...orderParams,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/contractSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/contractApprove'
            }
          })
          break
        case 'UQ':
          if (!this.unlocking('0104040200')) {
            this.$Message.info('无权限！')
            return false
          }
          this.$router.push({
            name: !isView ? 'refundOrderDetail' : 'viewRefundOrderDetail',
            query: {
              examineBtn: false,
              orderStatusName: '退签',
              ApproveManagementFlag,
              ...orderParams,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/contractSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/contractApprove'
            }
          })
          break
        case 'TR':
          this.$router.push({
            name: !isView ? 'subApproveDetailCase' : 'subApproveDetail',
            query: {
              adjustmentId: orderParams.businessId,
              ApproveManagementFlag,
              orderType: orderParams.orderType,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/subSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/subApprove'
            }
          })
          break
        case 'TQ':
          this.$router.push({
            name: !isView ? 'contractApproveDetailCase' : 'contractApproveDetail',
            query: {
              adjustmentId: orderParams.businessId,
              ApproveManagementFlag,
              orderType: orderParams.orderType,
              isSummary: isSummary,
              returnNote: returnNote,
              returnPurchase: returnPurchase,
              cusPreFlag:cusPreFlag,
              parentPath: !isView
                ? ''
                : isSummary
                ? '/salesManagement/contractSummary'
                : returnNote
                ? '/flowApproval/returnNotePurchase/returnNote'
                : returnPurchase
                ? '/flowApproval/returnNotePurchase/returnPurchase'
                : ApproveManagementFlag
                ? '/flowApproval/approveMgr/orderAdjustApproveManagement'
                : cusPreFlag
                ? '/reportCenter/financialReport/cusPreReport'
                : '/flowApproval/orderAdjustApprove/contractApprove'
            }
          })
          break
        default:
          break
      }
    }
  }
}
